package com.yykt.weshare.Exception;

import com.yykt.weshare.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(AppException.class)
    public JsonResult handleAppException(AppException e) {
        log.error("handleAppException:", e);
        return JsonResult.error(e.getCode(), e.getMessage());
    }
}
